import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AreaVO, AreaForm, AreaQuery } from '@/api/cemetery/area/types';

/**
 * 查询墓穴区域列表
 * @param query
 * @returns {*}
 */

export const listArea = (query?: AreaQuery): AxiosPromise<AreaVO[]> => {
  return request({
    url: '/cemetery/area/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询墓穴区域详细
 * @param id
 */
export const getArea = (id: string | number): AxiosPromise<AreaVO> => {
  return request({
    url: '/cemetery/area/' + id,
    method: 'get'
  });
};

/**
 * 新增墓穴区域
 * @param data
 */
export const addArea = (data: AreaForm) => {
  return request({
    url: '/cemetery/area',
    method: 'post',
    data: data
  });
};

/**
 * 修改墓穴区域
 * @param data
 */
export const updateArea = (data: AreaForm) => {
  return request({
    url: '/cemetery/area',
    method: 'put',
    data: data
  });
};

/**
 * 删除墓穴区域
 * @param id
 */
export const delArea = (id: string | number | Array<string | number>) => {
  return request({
    url: '/cemetery/area/' + id,
    method: 'delete'
  });
};
